home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / amigaunits / console.pas < prev    next >
Pascal/Delphi Source File  |  2000-01-01  |  4KB  |  156 lines

  1. {
  2.     This file is part of the Free Pascal run time library.
  3.  
  4.     A file in Amiga system run time library.
  5.     Copyright (c) 1998-2000 by Nils Sjoholm
  6.     member of the Amiga RTL development team.
  7.  
  8.     See the file COPYING.FPC, included in this distribution,
  9.     for details about the copyright.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14.  
  15.  **********************************************************************}
  16.  
  17. {
  18.     To call the two routines defined below, you'll need to set
  19.     ConsoleBase to an appropriate value.
  20. }
  21.  
  22. unit console;
  23.  
  24. INTERFACE
  25.  
  26. uses exec, inputevent, keymap;
  27.  
  28.  
  29. const
  30.  
  31. {***** Console commands *****}
  32.  
  33.      CD_ASKKEYMAP               = CMD_NONSTD + 0;
  34.      CD_SETKEYMAP               = CMD_NONSTD + 1;
  35.      CD_ASKDEFAULTKEYMAP        = CMD_NONSTD + 2;
  36.      CD_SETDEFAULTKEYMAP        = CMD_NONSTD + 3;
  37.  
  38.  
  39. {***** SGR parameters *****}
  40.  
  41.     SGR_PRIMARY         = 0;
  42.     SGR_BOLD            = 1;
  43.     SGR_ITALIC          = 3;
  44.     SGR_UNDERSCORE      = 4;
  45.     SGR_NEGATIVE        = 7;
  46.  
  47.     SGR_NORMAL          = 22;      { default foreground color, not bold }
  48.     SGR_NOTITALIC       = 23;
  49.     SGR_NOTUNDERSCORE   = 24;
  50.     SGR_POSITIVE        = 27;
  51.  
  52. { these names refer to the ANSI standard, not the implementation }
  53.  
  54.     SGR_BLACK           = 30;
  55.     SGR_RED             = 31;
  56.     SGR_GREEN           = 32;
  57.     SGR_YELLOW          = 33;
  58.     SGR_BLUE            = 34;
  59.     SGR_MAGENTA         = 35;
  60.     SGR_CYAN            = 36;
  61.     SGR_WHITE           = 37;
  62.     SGR_DEFAULT         = 39;
  63.  
  64.     SGR_BLACKBG         = 40;
  65.     SGR_REDBG           = 41;
  66.     SGR_GREENBG         = 42;
  67.     SGR_YELLOWBG        = 43;
  68.     SGR_BLUEBG          = 44;
  69.     SGR_MAGENTABG       = 45;
  70.     SGR_CYANBG          = 46;
  71.     SGR_WHITEBG         = 47;
  72.     SGR_DEFAULTBG       = 49;
  73.  
  74. { these names refer to the implementation, they are the preferred   }
  75. { names for use with the Amiga console device.        }
  76.  
  77.     SGR_CLR0            = 30;
  78.     SGR_CLR1            = 31;
  79.     SGR_CLR2            = 32;
  80.     SGR_CLR3            = 33;
  81.     SGR_CLR4            = 34;
  82.     SGR_CLR5            = 35;
  83.     SGR_CLR6            = 36;
  84.     SGR_CLR7            = 37;
  85.  
  86.     SGR_CLR0BG          = 40;
  87.     SGR_CLR1BG          = 41;
  88.     SGR_CLR2BG          = 42;
  89.     SGR_CLR3BG          = 43;
  90.     SGR_CLR4BG          = 44;
  91.     SGR_CLR5BG          = 45;
  92.     SGR_CLR6BG          = 46;
  93.     SGR_CLR7BG          = 47;
  94.  
  95.  
  96. {***** DSR parameters *****}
  97.  
  98.     DSR_CPR             = 6;
  99.  
  100. {***** CTC parameters *****}
  101.  
  102.     CTC_HSETTAB         = 0;
  103.     CTC_HCLRTAB         = 2;
  104.     CTC_HCLRTABSALL     = 5;
  105.  
  106. {*****   TBC parameters *****}
  107.  
  108.     TBC_HCLRTAB         = 0;
  109.     TBC_HCLRTABSALL     = 3;
  110.  
  111. {*****   SM and RM parameters *****}
  112.  
  113.     M_LNM               = 20;           { linefeed newline mode }
  114.     M_ASM               = '>1';         { auto scroll mode }
  115.     M_AWM               = '?7';         { auto wrap mode }
  116.  
  117. VAR ConsoleDevice : pDevice;
  118.  
  119. FUNCTION CDInputHandler(events : pInputEvent; consoleDev : pLibrary) : pInputEvent;
  120. FUNCTION RawKeyConvert(events : pInputEvent; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : LONGINT;
  121.  
  122. IMPLEMENTATION
  123.  
  124. FUNCTION CDInputHandler(events : pInputEvent; consoleDev : pLibrary) : pInputEvent;
  125. BEGIN
  126.   ASM
  127.     MOVE.L  A6,-(A7)
  128.     MOVEA.L events,A0
  129.     MOVEA.L consoleDev,A1
  130.     MOVEA.L ConsoleDevice,A6
  131.     JSR -042(A6)
  132.     MOVEA.L (A7)+,A6
  133.     MOVE.L  D0,@RESULT
  134.   END;
  135. END;
  136.  
  137. FUNCTION RawKeyConvert(events : pInputEvent; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : LONGINT;
  138. BEGIN
  139.   ASM
  140.     MOVE.L  A6,-(A7)
  141.     MOVEA.L events,A0
  142.     MOVEA.L buffer,A1
  143.     MOVE.L  length,D1
  144.     MOVEA.L keyMap,A2
  145.     MOVEA.L ConsoleDevice,A6
  146.     JSR -048(A6)
  147.     MOVEA.L (A7)+,A6
  148.     MOVE.L  D0,@RESULT
  149.   END;
  150. END;
  151.  
  152. END. (* UNIT CONSOLE *)
  153.  
  154.  
  155.  
  156.